-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix elided lifetimes shown as '_
on async functions
#80319
Conversation
7862711
to
25b628b
Compare
|
||
impl Foo { | ||
// @has async_fn/struct.Foo.html | ||
// @has - '//h4[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar) -> impl Iterator<Item = &usize>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment has been minimized.
This comment has been minimized.
25b628b
to
530c33c
Compare
// Turning `fn f(&'_ self)` into `fn f(&self)` isn't the worst thing in the world, though; | ||
// there's no case where it could cause the function to fail to compile. | ||
let elided = | ||
l.is_elided() || matches!(l.name, LifetimeName::Param(ParamName::Fresh(_))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that there are two possible ways we need to handle, when is it one versus the other? (Which test cases fail without one of these?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fresh
params aren't considered elided in rustc itself: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_hir/hir.rs.html#130-143. Almost every test fails without this, the only thing GenericParam
changes is removing the bogus fn f<'_>
.
If you notice above, it was already checking is_elided
, just not Fresh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. That makes me wonder if we should push this change up to is_elided()
, but that might have other side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test-cases look good, although I note that there are very few cases with &self
or &mut self
, which is where I typically see the issue.
5eda9c2
to
ceb66ad
Compare
@bors r+ |
📌 Commit ceb66ad has been approved by |
Rollup of 11 pull requests Successful merges: - rust-lang#79213 (Stabilize `core::slice::fill`) - rust-lang#79999 (Refactored verbose print into a function) - rust-lang#80160 (Implemented a compiler diagnostic for move async mistake) - rust-lang#80274 (Rename rustc_middle::lint::LintSource) - rust-lang#80280 (Add installation commands to `x` tool README) - rust-lang#80319 (Fix elided lifetimes shown as `'_` on async functions) - rust-lang#80327 (Updated the match with the matches macro) - rust-lang#80330 (Fix typo in simplify_try.rs) - rust-lang#80340 (Don't unnecessarily override attrs for Module) - rust-lang#80342 (Fix typo) - rust-lang#80352 (BTreeMap: make test cases more explicit on failure) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Closes #63037.
r? @tmandry on the implementation, @Darksonn on the test cases.